package com.qige.homework;

import java.util.Objects;
import java.util.Scanner;

public class homework8 {
    public static final User[] user = new User[3];
    static {
        user[0] = new User("jack","1234");
        user[1] = new User("rose","5678");
        user[2] = new User("tom","0000");
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入用户名:");
        String name = input.next();
        System.out.println("请输入密码");
        String password = input.next();

//        while (true){
//            int index = 0;
//            if (user[index].getName().equals(name) && user[index].getPassword().equals(password)){
//                System.out.println("登录结果:登陆成功");
//                break;
//            }
//            if (user[index].getName().equals(name) && !user[index].getPassword().equals(password)){
//                System.out.println("登录结果:密码错误");
//                break;
//            }
//            if (!user[index].getName().equals(name)){
//                if (user[index].getPassword().equals(password)){
//                    System.out.println("登录结果:用户名错误");
//                    break;
//                }else {
//                    if (index >= 3){
//                        System.out.println("登录结果:用户名和密码均错误");
//                        break;
//                    }
//                }
//            }
//            ++index;
//        }
    }
}
class User{
    private String name;
    private String password;

    public User() {
    }

    public User(String name, String password) {
        this.name = name;
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;
        return Objects.equals(name, user.name) && Objects.equals(password, user.password);
    }

    @Override
    public int hashCode() {
        int result = Objects.hashCode(name);
        result = 31 * result + Objects.hashCode(password);
        return result;
    }
}